using System;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Web;
namespace HKB.Common
{
	public class Conn
	{
		private static readonly Conn Myconn = new Conn(Conn.ConnectionStrings);
		private SqlConnection _conn;
		private bool _connected = false;
		private IDbTransaction _transaction = null;
		private IDbCommand _transCommand = null;
		public string ConnStr = "";
		public bool Connected
		{
			get
			{
				return this._connected;
			}
		}
		public static string CurrenConnectionStrings
		{
			get
			{
				return Conn.ConnectionStrings;
			}
		}
		private static string ConnectionStrings
		{
			get
			{
				string str = ConfigurationManager.AppSettings["AppPrefix"];
				string text = str + "HoWaveConnectionStrings";
				string result;
				if (HttpContext.Current.Cache[text] == null)
				{
					string text2 = ConfigurationManager.AppSettings["DataSource"];
					string text3 = ConfigurationManager.AppSettings["DBName"];
					string text4 = ConfigurationManager.AppSettings["LogName"];
					string text5 = ConfigurationManager.AppSettings["LogPassword"];
					string a = ConfigurationManager.AppSettings["IsEncrypt"];
					if (a == "true")
					{
						text2 = text2.Decrypt();
						text3 = text3.Decrypt();
						text4 = text4.Decrypt();
						text5 = text5.Decrypt();
					}
					string text6 = string.Format("Max Pool Size = 512;Data Source={0};Initial Catalog={1};user id={2};password={3}", new object[]
					{
						text2,
						text3,
						text4,
						text5
					});
					DataCache.SetCacheDepFile(text, text6, DataCache.webconfigfile);
					result = text6;
				}
				else
				{
					result = (string)HttpContext.Current.Cache[text];
				}
				return result;
			}
		}
		public IDbTransaction m_transaction
		{
			get
			{
				return this._transaction;
			}
		}
		public IDbCommand m_transCommand
		{
			get
			{
				return this._transCommand;
			}
		}
		public Conn()
		{
			this._conn = new SqlConnection(Conn.ConnectionStrings);
			this.openconn();
			this.ConnStr = Conn.ConnectionStrings;
		}
		public Conn(string connstr)
		{
			this._conn = new SqlConnection(connstr);
			this.openconn();
			this.ConnStr = connstr;
		}
		private void openconn()
		{
			if (!this._connected)
			{
				try
				{
					if (this._conn.State == ConnectionState.Broken)
					{
						this._conn.Close();
					}
					if (this._conn.State == ConnectionState.Closed)
					{
						this._conn.Open();
					}
					this._connected = true;
				}
				catch
				{
					this._conn.Close();
					this._conn.Dispose();
					this._conn = new SqlConnection(Conn.ConnectionStrings);
					this._conn.Open();
					this._connected = true;
				}
			}
		}
		public void OpenConn()
		{
			if (!this._connected)
			{
				try
				{
					this._conn = new SqlConnection(this.ConnStr);
					this._conn.Open();
					this._connected = true;
				}
				catch
				{
					throw new System.Exception("数据库连接失败...");
				}
			}
		}
		public void CloseConn()
		{
			if (this._connected)
			{
				try
				{
					this._conn.Close();
					this._connected = false;
				}
				catch
				{
					throw new System.Exception("数据库关闭失败！");
				}
			}
		}
		public int ExecuteCount(string sql)
		{
			int result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					try
					{
						result = System.Convert.ToInt32(sqlCommand.ExecuteScalar());
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
				}
			}
			return result;
		}
		public int Execute(string sql)
		{
			int result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
				sqlCommand.CommandTimeout = 0;
				try
				{
					result = System.Convert.ToInt32(sqlCommand.ExecuteNonQuery());
				}
				catch (System.Exception ex)
				{
					throw ex;
				}
				finally
				{
					if (sqlConnection.State == ConnectionState.Open)
					{
						sqlCommand.Dispose();
						sqlConnection.Close();
						this._connected = false;
					}
				}
			}
			return result;
		}
		public DataTable GetDataTable(string sql)
		{
			DataTable result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					DataTable dataTable = new DataTable();
					DbDataAdapter dbDataAdapter = new SqlDataAdapter(sqlCommand);
					try
					{
						dbDataAdapter.Fill(dataTable);
						result = dataTable;
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
				}
			}
			return result;
		}
		public static int GetMaxID(string FieldName, string TableName)
		{
			string sql = "select max(" + FieldName + ")+1 from " + TableName;
			object scalar = Conn.Myconn.GetScalar(sql, 1);
			int result;
			if (scalar == null)
			{
				result = 1;
			}
			else
			{
				result = int.Parse(scalar.ToString());
			}
			return result;
		}
		public static bool Exists(string strSql, params SqlParameter[] cmdParms)
		{
			object scalar = Conn.Myconn.GetScalar(strSql, cmdParms);
			int num;
			if (object.Equals(scalar, null) || object.Equals(scalar, System.DBNull.Value))
			{
				num = 0;
			}
			else
			{
				num = int.Parse(scalar.ToString());
			}
			return num != 0;
		}
		public DataSet GetDataSet(string sql)
		{
			DataSet result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
					DataSet dataSet = new DataSet();
					try
					{
						sqlDataAdapter.Fill(dataSet);
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
					result = dataSet;
				}
			}
			return result;
		}
		public DataSet GetDataSet(string procName, params SqlParameter[] parameters)
		{
			DataSet result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(procName, sqlConnection);
				sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				for (int i = 0; i < parameters.Length; i++)
				{
					SqlParameter value = parameters[i];
					sqlDataAdapter.SelectCommand.Parameters.Add(value);
				}
				DataSet dataSet = new DataSet();
				try
				{
					sqlDataAdapter.Fill(dataSet);
					result = dataSet;
				}
				catch (System.Exception ex)
				{
					throw ex;
				}
			}
			return result;
		}
		public object GetScalar(string sql, int type)
		{
			object result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					try
					{
						result = sqlCommand.ExecuteScalar();
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
					finally
					{
						if (sqlConnection.State == ConnectionState.Open)
						{
							sqlConnection.Close();
							this._connected = false;
						}
					}
				}
			}
			return result;
		}
		public IDataReader GetReader(string sql)
		{
			SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings);
			if (sqlConnection.State == ConnectionState.Closed)
			{
				sqlConnection.Open();
				this._connected = true;
			}
			IDbCommand dbCommand = new SqlCommand(sql, sqlConnection);
			dbCommand.CommandTimeout = 0;
			IDataReader result;
			try
			{
				result = dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
			}
			catch (System.Exception ex)
			{
				throw ex;
			}
			return result;
		}
		public int Execute(string procName, params SqlParameter[] parameters)
		{
			int result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				SqlCommand sqlCommand = new SqlCommand(procName, sqlConnection);
				sqlCommand.CommandTimeout = 0;
				sqlCommand.CommandType = CommandType.StoredProcedure;
				for (int i = 0; i < parameters.Length; i++)
				{
					SqlParameter value = parameters[i];
					sqlCommand.Parameters.Add(value);
				}
				try
				{
					result = System.Convert.ToInt32(sqlCommand.ExecuteNonQuery());
				}
				catch (System.Exception ex)
				{
					throw ex;
				}
				finally
				{
					if (sqlConnection.State == ConnectionState.Open)
					{
						sqlCommand.Dispose();
						sqlConnection.Close();
						this._connected = false;
					}
				}
			}
			return result;
		}
		public object GetScalarPro(string procName, params SqlParameter[] parameters)
		{
			object result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(procName, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					sqlCommand.CommandType = CommandType.StoredProcedure;
					for (int i = 0; i < parameters.Length; i++)
					{
						SqlParameter value = parameters[i];
						sqlCommand.Parameters.Add(value);
					}
					try
					{
						result = sqlCommand.ExecuteScalar();
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
					finally
					{
						if (sqlConnection.State == ConnectionState.Open)
						{
							sqlCommand.Dispose();
							sqlConnection.Close();
							this._connected = false;
						}
					}
				}
			}
			return result;
		}
		public IDataReader GetReader(string procName, params SqlParameter[] parameters)
		{
			SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings);
			if (sqlConnection.State == ConnectionState.Closed)
			{
				sqlConnection.Open();
				this._connected = true;
			}
			IDbCommand dbCommand = new SqlCommand(procName, sqlConnection);
			dbCommand.CommandTimeout = 0;
			dbCommand.CommandType = CommandType.StoredProcedure;
			for (int i = 0; i < parameters.Length; i++)
			{
				SqlParameter value = parameters[i];
				dbCommand.Parameters.Add(value);
			}
			IDataReader result;
			try
			{
				result = dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
			}
			catch (System.Exception ex)
			{
				throw ex;
			}
			return result;
		}
		public DataTable GetDataTable(string procName, params SqlParameter[] parameters)
		{
			DataTable result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(procName, sqlConnection);
				sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				for (int i = 0; i < parameters.Length; i++)
				{
					SqlParameter value = parameters[i];
					sqlDataAdapter.SelectCommand.Parameters.Add(value);
				}
				DataSet dataSet = new DataSet();
				try
				{
					sqlDataAdapter.Fill(dataSet);
					result = dataSet.Tables[0];
				}
				catch (System.Exception ex)
				{
					throw ex;
				}
			}
			return result;
		}
		public int ExecuteCount(string sql, params IDbDataParameter[] parameters)
		{
			int result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					for (int i = 0; i < parameters.Length; i++)
					{
						sqlCommand.Parameters.Add(parameters[i]);
					}
					try
					{
						int num = System.Convert.ToInt32(sqlCommand.ExecuteScalar());
						sqlCommand.Parameters.Clear();
						result = num;
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
				}
			}
			return result;
		}
		public int Execute(string commandText, params IDbDataParameter[] parameters)
		{
			int result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(commandText, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					for (int i = 0; i < parameters.Length; i++)
					{
						IDbDataParameter dbDataParameter = parameters[i];
						if (dbDataParameter != null)
						{
							if ((dbDataParameter.Direction == ParameterDirection.InputOutput || dbDataParameter.Direction == ParameterDirection.Input) && dbDataParameter.Value == null)
							{
								dbDataParameter.Value = System.DBNull.Value;
							}
							sqlCommand.Parameters.Add(dbDataParameter);
						}
					}
					try
					{
						result = sqlCommand.ExecuteNonQuery();
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
				}
			}
			return result;
		}
		public static int ExecuteSql(string commandText, params IDbDataParameter[] parameters)
		{
			return Conn.Myconn.Execute(commandText, parameters);
		}
		public DataTable GetDataTable(string commandText, params IDbDataParameter[] parameters)
		{
			DataTable result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(commandText, sqlConnection);
				for (int i = 0; i < parameters.Length; i++)
				{
					IDbDataParameter value = parameters[i];
					sqlDataAdapter.SelectCommand.Parameters.Add(value);
				}
				DataSet dataSet = new DataSet();
				try
				{
					sqlDataAdapter.Fill(dataSet);
					result = dataSet.Tables[0];
				}
				catch (System.Exception ex)
				{
					throw ex;
				}
			}
			return result;
		}
		public DataSet GetDataSet(string commandText, params IDbDataParameter[] parameters)
		{
			DataSet result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(commandText, sqlConnection);
				for (int i = 0; i < parameters.Length; i++)
				{
					IDbDataParameter value = parameters[i];
					sqlDataAdapter.SelectCommand.Parameters.Add(value);
				}
				DataSet dataSet = new DataSet();
				try
				{
					sqlDataAdapter.Fill(dataSet);
					result = dataSet;
				}
				catch (System.Exception ex)
				{
					throw ex;
				}
			}
			return result;
		}
		public static DataSet Query(string commandText, params IDbDataParameter[] parameters)
		{
			return Conn.Myconn.GetDataSet(commandText, parameters);
		}
		public object GetScalar(string commandText, params IDbDataParameter[] parameters)
		{
			object result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				if (sqlConnection.State == ConnectionState.Closed)
				{
					sqlConnection.Open();
					this._connected = true;
				}
				using (SqlCommand sqlCommand = new SqlCommand(commandText, sqlConnection))
				{
					sqlCommand.CommandTimeout = 0;
					for (int i = 0; i < parameters.Length; i++)
					{
						IDbDataParameter dbDataParameter = parameters[i];
						if ((dbDataParameter.Direction == ParameterDirection.InputOutput || dbDataParameter.Direction == ParameterDirection.Input) && dbDataParameter.Value == null)
						{
							dbDataParameter.Value = System.DBNull.Value;
						}
						sqlCommand.Parameters.Add(dbDataParameter);
					}
					try
					{
						result = sqlCommand.ExecuteScalar();
					}
					catch (System.Exception ex)
					{
						throw ex;
					}
				}
			}
			return result;
		}
		public static object GetSingle(string commandText, params IDbDataParameter[] parameters)
		{
			return Conn.Myconn.GetScalar(commandText, parameters);
		}
		public IDataReader GetReader(string commandText, params IDbDataParameter[] parameters)
		{
			SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings);
			if (sqlConnection.State == ConnectionState.Closed)
			{
				sqlConnection.Open();
				this._connected = true;
			}
			IDbCommand dbCommand = new SqlCommand(commandText, sqlConnection);
			dbCommand.CommandTimeout = 0;
			for (int i = 0; i < parameters.Length; i++)
			{
				dbCommand.Parameters.Add(parameters[i]);
			}
			IDataReader result;
			try
			{
				result = dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
			}
			catch (System.Exception ex)
			{
				throw ex;
			}
			return result;
		}
		public IDbDataParameter CreateParameter(string parameterName, DbType dbType, object value)
		{
			return new SqlParameter
			{
				ParameterName = parameterName,
				DbType = dbType,
				Value = value
			};
		}
		public SqlParameter CreateSQlParameter(string parameterName, SqlDbType dbType, object value, ParameterDirection Direction)
		{
			return new SqlParameter
			{
				ParameterName = parameterName,
				SqlDbType = dbType,
				Value = value,
				Direction = Direction
			};
		}
		public SqlParameter CreateParameter(string parameterName, SqlDbType SqldbType, object value)
		{
			return new SqlParameter
			{
				ParameterName = parameterName,
				SqlDbType = SqldbType,
				SqlValue = value
			};
		}
		public void BeginTransaction()
		{
			if (this._conn.State == ConnectionState.Closed)
			{
				this._conn.Open();
				this._connected = true;
			}
			this._transaction = this._conn.BeginTransaction();
		}
		public void Commit()
		{
			this._transaction.Commit();
			if (this._transCommand != null)
			{
				this._transCommand.Dispose();
			}
			this._transaction.Dispose();
		}
		public void Rollback()
		{
			this._transaction.Rollback();
			if (this._transCommand != null)
			{
				this._transCommand.Dispose();
			}
			this._transaction.Dispose();
		}
		public int ExecuteTransaction(string commandText)
		{
			if (this._conn.State == ConnectionState.Closed)
			{
				this._conn.Open();
				this._connected = true;
			}
			if (null == this._transCommand)
			{
				this._transCommand = new SqlCommand(commandText, this._conn);
				this._transCommand.Transaction = this._transaction;
			}
			else
			{
				this._transCommand.CommandText = commandText;
				if (this._transCommand.Transaction == null)
				{
					this._transCommand.Transaction = this._transaction;
				}
			}
			return this._transCommand.ExecuteNonQuery();
		}
		public int ExecuteTransaction(string commandText, params IDbDataParameter[] parameters)
		{
			if (this._conn.State == ConnectionState.Closed)
			{
				this._conn.Open();
				this._connected = true;
			}
			if (null == this._transCommand)
			{
				this._transCommand = new SqlCommand(commandText, this._conn);
				this._transCommand.Transaction = this._transaction;
			}
			else
			{
				this._transCommand.CommandText = commandText;
			}
			this._transCommand.Parameters.Clear();
			for (int i = 0; i < parameters.Length; i++)
			{
				if ((parameters[i].Direction == ParameterDirection.InputOutput || parameters[i].Direction == ParameterDirection.Input) && parameters[i].Value == null)
				{
					parameters[i].Value = System.DBNull.Value;
				}
				this._transCommand.Parameters.Add(parameters[i]);
			}
			return this._transCommand.ExecuteNonQuery();
		}
		public object ExecuteTransactionScalar(string commandText)
		{
			if (null == this._transCommand)
			{
				this._transCommand = new SqlCommand(commandText, this._conn);
				this._transCommand.Transaction = this._transaction;
			}
			else
			{
				this._transCommand.CommandText = commandText;
			}
			return this._transCommand.ExecuteScalar();
		}
		public object ExecuteTransactionScalar(string commandText, params IDbDataParameter[] parameters)
		{
			if (this._conn.State == ConnectionState.Closed)
			{
				this._conn.Open();
			}
			if (null == this._transCommand)
			{
				this._transCommand = new SqlCommand(commandText, this._conn);
				this._transCommand.Transaction = this._transaction;
			}
			else
			{
				this._transCommand.CommandText = commandText;
			}
			this._transCommand.Parameters.Clear();
			for (int i = 0; i < parameters.Length; i++)
			{
				if ((parameters[i].Direction == ParameterDirection.InputOutput || parameters[i].Direction == ParameterDirection.Input) && parameters[i].Value == null)
				{
					parameters[i].Value = System.DBNull.Value;
				}
				this._transCommand.Parameters.Add(parameters[i]);
			}
			return this._transCommand.ExecuteScalar();
		}
		public DataTable getDataTableCommand(string sql)
		{
			if (null == this._transCommand)
			{
				this._transCommand = new SqlCommand(sql, this._conn);
				this._transCommand.Transaction = this._transaction;
			}
			else
			{
				this._transCommand.CommandText = sql;
			}
			DataTable dataTable = new DataTable();
			DbDataAdapter dbDataAdapter = new SqlDataAdapter((SqlCommand)this._transCommand);
			dbDataAdapter.Fill(dataTable);
			return dataTable;
		}
		public static DataSet ExecProSpPageOrder(string tblName, string fldName, int PageSize, int PageIndex, string Orderfld, int OrderType, string strWhere)
		{
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@tblName", SqlDbType.VarChar, 255),
				new SqlParameter("@fldName", SqlDbType.VarChar, 255),
				new SqlParameter("@PageSize", SqlDbType.Int),
				new SqlParameter("@PageIndex", SqlDbType.Int),
				new SqlParameter("@IsReCount", SqlDbType.Bit),
				new SqlParameter("@OrderType", SqlDbType.Bit),
				new SqlParameter("@strWhere", SqlDbType.VarChar, 1000),
				new SqlParameter("@OrderfldName", SqlDbType.VarChar, 255)
			};
			array[0].Value = tblName;
			array[1].Value = fldName;
			array[2].Value = PageSize;
			array[3].Value = PageIndex;
			array[4].Value = 1;
			array[5].Value = OrderType;
			array[6].Value = strWhere;
			array[7].Value = Orderfld;
			return Conn.ExecProDataSet("SpPageOrder", array);
		}
		private static SqlCommand BuildQueryCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
		{
			SqlCommand sqlCommand = new SqlCommand(storedProcName, connection);
			sqlCommand.CommandType = CommandType.StoredProcedure;
			for (int i = 0; i < parameters.Length; i++)
			{
				SqlParameter sqlParameter = (SqlParameter)parameters[i];
				if (sqlParameter != null)
				{
					if ((sqlParameter.Direction == ParameterDirection.InputOutput || sqlParameter.Direction == ParameterDirection.Input) && sqlParameter.Value == null)
					{
						sqlParameter.Value = System.DBNull.Value;
					}
					sqlCommand.Parameters.Add(sqlParameter);
				}
			}
			return sqlCommand;
		}
		public static DataSet ExecProDataSet(string ProName, params SqlParameter[] values)
		{
			DataSet result;
			using (SqlConnection sqlConnection = new SqlConnection(Conn.ConnectionStrings))
			{
				DataSet dataSet = new DataSet();
				using (SqlCommand sqlCommand = Conn.BuildQueryCommand(sqlConnection, ProName, values))
				{
					sqlCommand.CommandType = CommandType.StoredProcedure;
					using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand))
					{
						sqlDataAdapter.Fill(dataSet);
						sqlCommand.Parameters.Clear();
						result = dataSet;
					}
				}
			}
			return result;
		}
	}
}
